package com.xhwl.logistics.converter.mapstruct;

import com.xhwl.logistics.bo.VehicleBlacklistBO;
import com.xhwl.logistics.bo.input.QueryVehicleBlacklistBO;
import com.xhwl.logistics.bo.manipulate.CreateVehicleBlacklistBO;
import com.xhwl.logistics.bo.manipulate.CreateVehicleBlacklistHttpBO;
import com.xhwl.logistics.bo.manipulate.DeleteVehicleBlacklistBO;
import com.xhwl.logistics.bo.manipulate.DeleteVehicleBlacklistHttpBO;
import com.xhwl.logistics.bo.manipulate.UpdateVehicleBlacklistBO;
import com.xhwl.logistics.dto.http.manipulation.AddCarBlackKeTopDTO;
import com.xhwl.logistics.dto.http.manipulation.DeleteCarBlackKeTopDTO;
import com.xhwl.logistics.dto.manipulate.VehicleBlacklistCreateDTO;
import com.xhwl.logistics.dto.manipulate.VehicleBlacklistDeleteDTO;
import com.xhwl.logistics.dto.manipulate.VehicleBlacklistUpdateDTO;
import com.xhwl.logistics.dto.query.VehicleBlacklistDTO;
import com.xhwl.logistics.entity.VehicleBlacklist;
import com.xhwl.logistics.vo.VehicleBlacklistVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.NullValueMappingStrategy;

import java.util.List;
import java.util.stream.Collectors;

@Mapper(nullValueMappingStrategy = NullValueMappingStrategy.RETURN_DEFAULT)
public interface VehicleBlacklistConverter {

    //*********Query BO <- Controller DTO*********
    QueryVehicleBlacklistBO vehicleBlacklistDTO2QueryVehicleBlacklistBO(VehicleBlacklistDTO vehicleBlacklistDTO);
    //*********Query BO <- Controller DTO*********


    //*********BO <- Entity*********
    List<VehicleBlacklistBO> vehicleBlacklistList2VehicleBlacklistBOList(List<VehicleBlacklist> vehicleBlacklistList);
    VehicleBlacklistBO vehicleBlacklist2VehicleBlacklistBO(VehicleBlacklist vehicleBlacklist);
    //*********BO <- Entity*********


    //*********VO <- BO*********
    List<VehicleBlacklistVO> vehicleBlacklistBOList2VehicleBlacklistVOList(List<VehicleBlacklistBO> vehicleBlacklistBOList);
    VehicleBlacklistVO vehicleBlacklistBO2VehicleBlacklistVO(VehicleBlacklistBO vehicleBlacklistBO);
    //*********VO <- BO*********


    //*********Create BO <- Controller Create DTO*********
    @Mapping(target = "creatorAccountId", source = "id")
    @Mapping(target = "creatorAccountName", source = "name")
    CreateVehicleBlacklistBO toCreateVehicleBlacklistBO(VehicleBlacklistCreateDTO vehicleBlacklistCreateDTO, Integer id, String name);
    //*********Create BO <- Controller Create DTO*********
    //*********Entity <- Create BO*********
    VehicleBlacklist createVehicleBlacklistBO2VehicleBlacklist(CreateVehicleBlacklistBO createVehicleBlacklistBO, String projectName, Integer parkingLotId);
    //*********Entity <- Create BO*********
    //*********Create Http BO <- Create BO*********
    CreateVehicleBlacklistHttpBO createVehicleBlacklistBO2CreateVehicleBlacklistHttpBO(CreateVehicleBlacklistBO createVehicleBlacklistBO);
    //*********Create Http BO <- Create BO*********

    //*********Entity <- *********
    default List<VehicleBlacklist> toVehicleBlacklistList(List<String> plateNumberList, Integer projectId, String projectName, Integer parkingLotId, String parkingLotName, String creatorAccountName) {
        return plateNumberList.stream()
                .map(plateNumber -> toVehicleBlacklist(plateNumber, projectId, projectName, parkingLotId, parkingLotName, creatorAccountName))
                .collect(Collectors.toList());
    }
    VehicleBlacklist toVehicleBlacklist(String plateNumber, Integer projectId, String projectName, Integer parkingLotId, String parkingLotName, String creatorAccountName);
    //*********Entity <- *********


    //*********Delete BO <- Controller Delete DTO*********
    @Mapping(target = "deleterAccountId", source = "accountId")
    @Mapping(target = "deleterAccountName", source = "accountName")
    DeleteVehicleBlacklistBO vehicleBlacklistDeleteDTO2DeleteVehicleBlacklistBO(VehicleBlacklistDeleteDTO vehicleBlacklistDeleteDTO, Integer accountId, String accountName);
    //*********Delete BO <- Controller Delete DTO*********


    //*********Update BO <- Controller Update DTO*********
    @Mapping(target = "editorAccountId", source = "accountId")
    @Mapping(target = "editorAccountName", source = "accountName")
    UpdateVehicleBlacklistBO vehicleBlacklistUpdateDTO2UpdateVehicleBlacklistBO(VehicleBlacklistUpdateDTO vehicleBlacklistUpdateDTO, Integer accountId, String accountName);
    //*********Update BO <- Controller Update DTO*********

    //*********Entity <- Update BO*********
    VehicleBlacklist updateVehicleBlacklistBO2VehicleBlacklist(UpdateVehicleBlacklistBO updateVehicleBlacklistBO);
    //*********Entity <- Update BO*********


    //*********Ke Top*********
    //*********Http DTO <- Http BO*********
    default AddCarBlackKeTopDTO createVehicleBlacklistHttpBO2AddCarBlackKeTopDTO(CreateVehicleBlacklistHttpBO createVehicleBlacklistHttpBO) {
        AddCarBlackKeTopDTO addCarBlackKeTopDTO = new AddCarBlackKeTopDTO();

        String plateNumber = createVehicleBlacklistHttpBO.getPlateNumber();
        addCarBlackKeTopDTO.setPlateNo(plateNumber);
        addCarBlackKeTopDTO.setRemark("add blacklist for " + plateNumber);
        addCarBlackKeTopDTO.setType(3);
        return addCarBlackKeTopDTO;
    }
    default DeleteCarBlackKeTopDTO deleteVehicleBlacklistHttpBO2DeleteCarBlackKeTopDTO(DeleteVehicleBlacklistHttpBO deleteVehicleBlacklistHttpBO) {
        DeleteCarBlackKeTopDTO deleteCarBlackKeTopDTO = new DeleteCarBlackKeTopDTO();

        String plateNumber = deleteVehicleBlacklistHttpBO.getPlateNumber();
        deleteCarBlackKeTopDTO.setPlateNo(plateNumber);
        deleteCarBlackKeTopDTO.setRemark("delete blacklist for " + plateNumber);
        return deleteCarBlackKeTopDTO;
    }
    //*********Http DTO <- Http BO*********
    //*********Ke Top*********

}
